package ui.swing;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;
import javax.swing.JTable;

import ui.swing.table.StockTable;

import data.DataBuffer;

import analyse.RecommandOnTime;

public class StockTableUI {

	private JFrame frame;
	private StockTable tableAverLine;
	private StockTable tableCare;
	private StockTable tableLowUP;
	private StockTable tableOwn;
	private StockTable tableHeadRun;
	private StockTable tableSinaInd;
	private StockTable tableBat;
	private StockTable tableFinalSel;
	private StockTable tableUpline;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					StockTableUI window = new StockTableUI();
//					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public StockTableUI() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBackground(Color.WHITE);
		frame.setBounds(100, 100, 1106, 720);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.getContentPane().setLayout(new GridLayout(3, 3, 0, 0));
		frame.getContentPane().setBackground(Color.WHITE);
		
		tableOwn = new StockTable(0);
		tableCare = new StockTable(1);
		tableFinalSel = new StockTable(2);
		tableHeadRun = new StockTable(3);
		tableSinaInd = new StockTable(4);
		tableLowUP = new StockTable(5);
		tableAverLine = new StockTable(6);
		tableUpline = new StockTable(7);
		tableBat = new StockTable(8);
		
		frame.add(tableOwn);
		frame.add(tableCare);
		frame.add(tableFinalSel);
		frame.add(tableHeadRun);
		frame.add(tableSinaInd);
		frame.add(tableLowUP);
		frame.add(tableAverLine);
		frame.add(tableUpline);
		frame.add(tableBat);
		
		frame.setVisible(true);
		
		frame.addWindowListener(new WindowListener() {
			
			@Override
			public void windowOpened(WindowEvent e) {
			}
			
			@Override
			public void windowIconified(WindowEvent e) {
			}
			
			@Override
			public void windowDeiconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowDeactivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowClosing(WindowEvent e) {
				tableOwn.killModelThread();
				tableCare.killModelThread();
				tableFinalSel.killModelThread();
				tableHeadRun.killModelThread();
				tableSinaInd.killModelThread();
				tableLowUP.killModelThread();
				tableAverLine.killModelThread();
				tableUpline.killModelThread();
				tableBat.killModelThread();
			}
			
			@Override
			public void windowClosed(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	
}
